<template>
  <span v-if="showBadge" class="role-badge" :class="badgeClass">
    {{ badgeText }}
  </span>
</template>

<script setup>
import { computed } from 'vue'

const props = defineProps({
  roles: {
    type: Array,
    default: () => []
  }
})

const showBadge = computed(() => {
  return props.roles && props.roles.length > 0
})

const isSuperAdmin = computed(() => {
  return props.roles.includes('super_admin')
})

const badgeClass = computed(() => {
  return isSuperAdmin.value ? 'super-admin' : 'common-user'
})

const badgeText = computed(() => {
  return isSuperAdmin.value ? '超级管理员' : '普通用户'
})
</script>

<style scoped>
.role-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 4px;
  font-weight: 500;
  margin-left: 6px;
}

.role-badge.super-admin {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
  color: white;
}

.role-badge.common-user {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
}
</style>
